﻿package mlc.haxe.input.formatting;

/**
 * A formatter that formats a string that represents a boolean value into a bool.
 */
class BoolFormatter implements InputFormatter<Bool> {
	/**
	 * Creates a new bool formatter.
	 */
	public function new():Void {
	}
	public function format(input:String):Bool {
		return 
			switch (input.toLowerCase()) {
				case "true", "1", "t":
				true;
				case "false", "0", "f":
				false;
				default:
				throw "\"" + input + "\" has an unexpected format, should be either \"true\" or \"false\"";
			}
	}
}